attribute vec4 a_Position;
attribute vec2 a_TexCoord;    
attribute vec4 a_Normal;

uniform mat4 u_ModelMatrix;
uniform mat4 u_ViewMatrix;
uniform mat4 u_ProjMatrix;
uniform mat4 u_NormalMatrix;
uniform vec3 u_LightColor;
uniform vec3 u_LightPosition;
uniform vec3 u_AmbientColor;

varying vec3 v_Light;
varying vec2 v_TexCoord; 

void main() {
   gl_Position = u_ProjMatrix * u_ViewMatrix * u_ModelMatrix * a_Position;
   vec3 normal = normalize(vec3(u_NormalMatrix * a_Normal));
   vec4 vertexPosition = u_ModelMatrix * a_Position;
   vec3 lightDirection = normalize(u_LightPosition - vec3(vertexPosition));
   float nDotL = max(dot(lightDirection, normal), 0.0);
   vec3 diffuse = u_LightColor * nDotL;
   vec3 ambient = u_AmbientColor;
   v_Light = diffuse + ambient;
   v_TexCoord = a_TexCoord;    
}
